home *** CD-ROM | disk | FTP | other *** search
- property pWindowName, pSpriteList, pMaxRect, pMinRect, pButtonList, pTracking, pPointingCursor, pMemberNum, pMember, pNArrowObj, pSArrowObj, pSliderObj, pFieldLeft, pFieldTop, pFieldRight, pFieldBottom, pLineHeight, pStartX, pStartTop, pStartBottom, pEndTop, pEndX, pEndBottom, pStartSel, pMiddleSel, pEndSel, pRolloverTextObj, pBorderRectList, pTextRectList
-
- on new me
- pButtonList = [:]
- pTracking = 0
- pPointingCursor = [member("point hand"), member("point hand mask")]
- return me
- end
-
- on init me
- NArrowSp = getaProp(pSpriteList, #NArrow)
- pNArrowObj = getaProp(pButtonList, NArrowSp)
- SArrowSp = getaProp(pSpriteList, #SArrow)
- pSArrowObj = getaProp(pButtonList, SArrowSp)
- ThumbSp = getaProp(pSpriteList, #VThumb)
- pSliderObj = getaProp(pButtonList, ThumbSp)
- FieldRect = the rect of sprite getaProp(pSpriteList, #text)
- pFieldLeft = getAt(FieldRect, 1)
- pFieldTop = getAt(FieldRect, 2)
- pFieldRight = getAt(FieldRect, 3)
- pFieldBottom = getAt(FieldRect, 4)
- pLineHeight = the textHeight of field pMemberNum
- member("texthold f").text = EMPTY
- SetPuppetState([7, 9], #c, 1)
- end
-
- on HiliteText me, clickedSprite
- pTracking = 1
- StartChar = the mouseChar
- repeat while the stillDown
- SelectionScroll(me)
- X = the mouseH
- Y = the mouseV
- if X <= pFieldLeft then
- X = pFieldLeft + 1
- end if
- if X >= pFieldRight then
- X = pFieldRight - 1
- end if
- if Y <= pFieldTop then
- Y = pFieldTop + 1
- end if
- if Y >= pFieldBottom then
- Y = pFieldBottom - 1
- end if
- EndChar = locToCharPos(member(pMemberNum), point(X - pFieldLeft, Y - pFieldTop))
- SetSelections(me, StartChar, EndChar)
- SetVisSelections(me)
- end repeat
- CalcFinalSelection(me, StartChar, EndChar)
- pTracking = 0
- end
-
- on SetSelections me, StartChar, EndChar
- TempStart = min(StartChar, EndChar)
- TempEnd = max(StartChar, EndChar)
- StartChar = TempStart
- EndChar = TempEnd
- StartLoc = charPosToLoc(member(pMemberNum), StartChar)
- pStartX = getAt(StartLoc, 1) + pFieldLeft
- pStartTop = getAt(StartLoc, 2) + pFieldTop - member(pMemberNum).scrollTop + GetHiliteAdjustment(me)
- pStartBottom = pStartTop + pLineHeight
- EndLoc = charPosToLoc(member(pMemberNum), EndChar)
- pEndTop = getAt(EndLoc, 2) + pFieldTop - member(pMemberNum).scrollTop + GetHiliteAdjustment(me)
- pEndX = getAt(EndLoc, 1) + pFieldLeft
- pEndBottom = pEndTop + pLineHeight
- if pStartTop = pEndTop then
- pStartSel = rect(pStartX, pStartTop, pEndX, pStartBottom)
- pEndSel = #NotUsed
- else
- if pStartTop < pEndTop then
- pStartSel = rect(pStartX, pStartTop, pFieldRight, pStartBottom)
- pEndSel = rect(pFieldLeft, pEndTop, pEndX, pEndBottom)
- end if
- end if
- SetMiddleSelection(me)
- end
-
- on SetMiddleSelection me
- if ilk(pEndSel) = #rect then
- pMiddleSel = rect(pFieldLeft, getAt(pStartSel, 4), pFieldRight, getAt(pEndSel, 2))
- else
- pMiddleSel = #NotUsed
- end if
- end
-
- on SetVisSelections me
- set the rect of sprite 7 to getVisSelection(me, pStartSel)
- set the rect of sprite 8 to getVisSelection(me, pEndSel)
- set the rect of sprite 9 to getVisSelection(me, pMiddleSel)
- updateStage()
- end
-
- on getVisSelection me, selRect
- if ilk(selRect) = #rect then
- R = rect(-1, -1, -1, -1)
- if not ((selRect.top > pFieldBottom) or (selRect.bottom < pFieldTop)) then
- R.left = max(selRect.left, pFieldLeft)
- R.top = max(selRect.top, pFieldTop)
- R.right = min(selRect.right, pFieldRight)
- R.bottom = min(selRect.bottom, pFieldBottom)
- end if
- else
- R = rect(-1, -1, -1, -1)
- end if
- return R
- end
-
- on SelectionScroll me
- if the mouseV < pFieldTop then
- if not minReached(pSliderObj) then
- simulateClickOn(pNArrowObj)
- end if
- else
- if the mouseV > pFieldBottom then
- if not maxReached(pSliderObj) then
- simulateClickOn(pSArrowObj)
- end if
- end if
- end if
- end
-
- on scroll me, NewSetting
- diff = NewSetting - (member(pMemberNum).scrollTop / pLineHeight)
- increment = diff * pLineHeight
- pStartSel = ScrollMoveSelection(me, pStartSel, increment)
- pEndSel = ScrollMoveSelection(me, pEndSel, increment)
- SetMiddleSelection(me)
- if not pTracking then
- SetVisSelections(me)
- end if
- return me
- end
-
- on ScrollMoveSelection me, SelectionRect, increment
- if ilk(SelectionRect) = #rect then
- SelectionRect.top = SelectionRect.top - increment
- SelectionRect.bottom = SelectionRect.bottom - increment
- end if
- return SelectionRect
- end
-
- on CalcFinalSelection me, StartChar, EndChar
- TempStart = min(StartChar, EndChar)
- TempEnd = max(StartChar, EndChar)
- StartChar = TempStart
- EndChar = TempEnd
- member("texthold f").text = char StartChar to EndChar - 1 of the text of field pMemberNum
- if not (member("texthold f").text = EMPTY) then
- enable(getaProp(pButtonList, getaProp(pSpriteList, #CopyButton)))
- else
- disable(getaProp(pButtonList, getaProp(pSpriteList, #CopyButton)))
- end if
- end
-
- on GetHiliteAdjustment me
- if the machineType = 256 then
- return -pLineHeight
- else
- return -pLineHeight
- end if
- end
-
- on ResetSelections me
- pStartSel = #NotUsed
- pMiddleSel = #NotUsed
- pEndSel = #NotUsed
- set the rect of sprite 7 to rect(-333, -333, -333, -333)
- set the rect of sprite 8 to rect(-333, -333, -333, -333)
- set the rect of sprite 9 to rect(-333, -333, -333, -333)
- updateStage()
- end
-
- on InitRollOverText me
- rolloverList = []
- setAt(rolloverList, getaProp(pSpriteList, #closeBox), 16)
- setAt(rolloverList, getaProp(pSpriteList, #CopyButton), 13)
- setAt(rolloverList, getaProp(pSpriteList, #PrintButton), 11)
- setAt(rolloverList, getaProp(pSpriteList, #SaveButton), 10)
- setAt(rolloverList, getaProp(pSpriteList, #MaxMinBox), 18)
- pRolloverTextObj = new(script("rollover text"), rolloverList)
- end
-
- on print me
- global gEnvironObj
- if not isMemoryAvailable("print the document", 1200, 500) then
- exit
- end if
- TitleMember = the number of member "print title f"
- xMember = GetMemberNum(me)
- unLoad()
- doc = new(xtra("PrintOMatic"))
- if not objectp(doc) then
- alert("A problem was encountered while initializing the printer.")
- exit
- end if
- pageW = getPageWidth(doc)
- pageH = getPageHeight(doc)
- set the textSize of member TitleMember to 14
- member(TitleMember).rect = rect(0, 0, pageW, 0)
- TitleH = member(TitleMember).height
- pgNumSym = numToChar(166)
- setPageNumSymbol(doc, pgNumSym)
- setTextJust(doc, "left")
- newPage(doc)
- setTextJust(doc, "centered")
- newFrame(doc, rect(0, 0, pageW, TitleH + 18), 0)
- append(doc, member(TitleMember), 0)
- setTextJust(doc, "left")
- newFrame(doc, rect(0, 0, pageW, pageH - 18), 0)
- append(doc, " ", 1)
- count = (TitleH / 14) + 1
- repeat with i = 1 to count
- append(doc, RETURN, 1)
- end repeat
- member("print media", 1).media = member(xMember, "DBText.CST").media
- append(doc, member("print media", 1), 1)
- if the machineType = 256 then
- setTextFont(doc, "Arial")
- else
- setTextFont(doc, "Helvetica")
- end if
- setTextSize(doc, 12)
- setTextStyle(doc, "normal")
- drawText(doc, member("copyright HRW").text, point(0, pageH))
- setDocumentName(doc, "American History")
- if doJobSetup(doc) then
- print(doc)
- end if
- doc = 0
- end
-
- on save me
- xMember = GetMemberNum(me)
- fileName = MakePlatformFileName(the text of field "title f" of castLib 1) & GetTextExtension()
- pathAndName = GetSavePathandName(fileName)
- if pathAndName <> EMPTY then
- saveTextFile(pathAndName, member(xMember).text)
- end if
- return me
- end
-
- on doRolloverText me
- doRolloverText(pRolloverTextObj)
- end
-
- on SetButtonList me, xList
- pButtonList = xList
- end
-
- on GetButtonList me
- return pButtonList
- end
-
- on ResizeScroll me, theThumbLoc, minPixel, maxPixel, initialSetting, numSettings, minSetting, maxSetting
- resize(pSliderObj, theThumbLoc, minPixel, maxPixel, initialSetting, numSettings, minSetting, maxSetting)
- end
-
- on SetBorderRect me, xList
- pBorderRectList = xList
- end
-
- on GetBorderRect me, size
- return getAt(pBorderRectList, size)
- end
-
- on SetTextRect me, xList
- pTextRectList = xList
- end
-
- on GetTextRect me, size
- return getAt(pTextRectList, size)
- end
-
- on GetPointingCursor me
- return pPointingCursor
- end
-
- on SetMemberNum me, Var
- pMemberNum = Var
- end
-
- on GetMemberNum me
- return pMemberNum
- end
-
- on SetMember me, xName
- pMember = xName
- end
-
- on GetMember me
- return pMember
- end
-
- on SetSpriteList me, list
- pSpriteList = list
- end
-
- on GetSpriteList me
- return pSpriteList
- end
-
- on condemn me
- pButtonList = CondemnList(me, pButtonList)
- condemn(pNArrowObj)
- pNArrowObj = 0
- condemn(pSArrowObj)
- pSArrowObj = 0
- condemn(pSliderObj)
- pSliderObj = 0
- pRolloverTextObj = 0
- return me
- end
-
- on CondemnList me, xList
- MaxCount = count(xList)
- repeat with rc = 1 to MaxCount
- xObj = getAt(xList, rc)
- condemn(xObj)
- setAt(xList, rc, 0)
- end repeat
- return 0
- end
-